package models

import (
	"github.com/beego/beego/v2/client/orm"
	"time"
)

type BannerImage struct {
	Id int64 `orm:"pk;auto;column(id)"`
	BannerName string `orm:"size(100);column(banner_name)"`
	CreateDate time.Time `orm:"type(date);column(create_date)"`
	UpdateDate time.Time `orm:"type(date);column(update_date)"`
	Delete int `orm:"type(int);column(delete)"`
	BannerUrl string `orm:"size(100);column(banner_url)"`
	BannerType string `orm:"size(100);column(banner_type)"`
	BannerLocation int `orm:"type(int);column(banner_location)"`
	Desc string `orm:"size(100);column(desc)"`
	BannerClickUrl string `orm:"size(100);column(banner_click_url)"`
}

func (b *BannerImage) TableName()string {
	return "t_banner_config"
}

func GetBannerListByType(bannerType string) []BannerImage {
	newOrm := orm.NewOrm()
	var sql = "select * from t_banner_config where banner_type =? and `delete` <> 1"
	var bannerList []BannerImage
	_, err := newOrm.Raw(sql, bannerType).QueryRows(&bannerList)
	if err!=nil{
		panic(err)
	}
	return bannerList
}
